package com.oracle.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.oracle.entity.po.SupplierPO;
import com.oracle.service.supplier.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/Supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;


    @RequestMapping(value = "getPage", method = RequestMethod.GET)
    @ResponseBody
    public Map<String, Object> getPage(@RequestParam("limit") int limit, @RequestParam("curr") int curr, HttpServletRequest request, HttpServletResponse response) {
        Page<SupplierPO> page = new Page<>(curr, limit);
        List list =supplierService.selectPage(page, null).getRecords();
        Integer count = supplierService.selectCount(null);
        Map<String, Object> jsonmap = new HashMap<String, Object>();
        jsonmap.put("code", 0);
        jsonmap.put("data", list);
        jsonmap.put("count", count);
        jsonmap.put("msg", "查询成功");
        return jsonmap;
    }


}